package com.lhj.library.infra.basic.service.impl;

import com.lhj.library.infra.basic.entity.Book;
import com.lhj.library.infra.basic.mapper.BookDao;
import com.lhj.library.infra.basic.service.BookService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Book)表服务实现类
 *
 * @author makejava
 * @since 2023-11-27 20:54:57
 */
@Service
public class BookServiceImpl implements BookService {
    @Resource
    private BookDao bookDao;

    /**
     * 通过ID查询单条数据
     *
     * @return 实例对象
     */
    @Override
    public Book queryById(Book book) {
        return this.bookDao.queryById(book);
    }


    /**
     * 新增数据
     *
     * @param book 实例对象
     * @return 实例对象
     */
    @Override
    public Integer insert(Book book) {
        return this.bookDao.insert(book);
    }

    /**
     * 修改数据
     *
     * @param book 实例对象
     * @return 实例对象
     */
    @Override
    public Integer update(Book book) {
        return this.bookDao.update(book);

    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.bookDao.deleteById(id) > 0;
    }

    @Override
    public int count(Book book) {
        return this.bookDao.count(book);
    }

    @Override
    public List<Book> selectByPage(Book book, Integer start, Integer pageSize) {
        return this.bookDao.selectByPage(book, start, pageSize);
    }
}
